<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>在备选元素之前插入内容</title>
		<script src="js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<h1>标题1</h1>
		<h2>标题2</h2>
		<h3>标题3</h3>
		<button type="button" id="bu1">之前插入</button>
	</body>
</html>
<script type="text/javascript">
	$(document).ready(() =>　{
		$("#bu1").click(() => {
			$("h2").before("<p>元素</p>");
		})
	})
</script>